package com.zgm.ch05.aop.after._3_5_4_1;

import java.lang.reflect.Method;

import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.framework.ProxyFactory;

import com.zgm.ch05.aop._3_2.MessageWriter;

public class SimpleAfterReturningAdvice implements AfterReturningAdvice {
	
	
	public static void main(String[] args){
		MessageWriter target = new MessageWriter();
		ProxyFactory pf = new ProxyFactory();
		
		pf.addAdvice(new SimpleAfterReturningAdvice());
		pf.setTarget(target);
		
		MessageWriter proxy = (MessageWriter) pf.getProxy();
		
		proxy.writeMessage();
	}
	
	public void afterReturning(Object returnValue, Method method, Object[] args, Object target){
		System.out.println("");
		System.out.println("After method: " + method.getName());
		
	}

}
